<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title>广告管理</title>
		<link rel="stylesheet" href="__AGENT__/css/iconfont.css" />
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
	</head>

	<body>
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right">
					<div class="rigtop">
						<span class="title">广告管理</span>
					</div>
					<div class="indrig_con" style="position: relative;">
						<div class="zizh_btnbox" style="top: -58px; right: 20px;">
							<button class="zizh_btn" type="button" onclick="add_ad()"><i class="iconfont icon-jia"></i>增加广告</button>
						</div>
						<div class="help_lisbox" style="position: relative;">
							<table class="zizh_table1">
								<thead>
									<tr>
										<th>标题</th>
										<th>发布时间</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody id="tbody">
									{volist name="list" id="vo" empty="这里没有数据"}
									<tr>
										<td>{$vo.title}</td>
										<td>{$vo.add_time}</td>
										<td>
											<a href="javascript:;" onclick="ad_edit({$vo.id})">编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;
											<a  href="javascript:;" onclick="ad_del({$vo.id})">删除</a>
										</td>
									</tr>
									{/volist}
								</tbody>
							</table>
							
						</div>
					</div>
				</div>
			</div>
		</div>
		{include file="public/footer" /}
	</body>

</html>
<script>
	function ad_del(id) {
		layer.confirm('确认要删除吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type: 'get',
				url: "{:url('shop/ad_del')}",
				dataType: 'json',
				data: {
					id: id
				},
				success: function(data) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
					if(data.code == 200) {
						location.reload();
					} 
				},
				error: function(data) {
					console.log(data.msg);
				}
			});
		});
	}

	function add_ad() {
		layer.open({
			type: 2,
			title: '添加广告',
			shadeClose: true,
			shade: 0.8,
			area: ['650px', '550px'],
			content: "{:url('ad_add')}"
		});
	}
	function ad_edit(id) {
			var url = 'ad_edit?id='+id;
		layer.open({
			type: 2,
			title: '添加广告',
			shadeClose: true,
			shade: 0.8,
			area: ['650px', '550px'],
			content: url
		});
	}
</script>